package com.hongkzh.www.look.media.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hongkzh.www.R;
import com.hongkzh.www.view.activity.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by as on 2018/4/13.
 * 自媒体招聘筛选一级页面
 */

public class RecruitScreenActivity extends BaseActivity implements View.OnClickListener {

    @BindView(R.id.layout_OperatingPost)
    RelativeLayout layoutOperatingPost;
    @BindView(R.id.layout_WorkArea)
    RelativeLayout layoutWorkArea;
    @BindView(R.id.tv_pay_range)
    TextView tvPayRange;
    @BindView(R.id.layout_PayRanges)
    RelativeLayout layoutPayRanges;
    @BindView(R.id.mBtn_Confirm)
    Button mBtnConfirm;

    private final int REQUESTCODEFORPOST = 1;

    private final int REQUESTFORAREA = 2;
    @BindView(R.id.tv_job_post)
    TextView tvJobPost;
    @BindView(R.id.tv_CityArea)
    TextView tvCityArea;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_recruitscreen);
        ButterKnife.bind(this);
        setTranslucent(R.color.color_D8D8D8);


    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_recruitscreen;
    }

    @Override
    protected void init() {
        mTiManager.setTitle("筛选");
        mTiManager.setLeftIcon(R.mipmap.arrow_left);
    }

    @Override
    protected void setListener() {

        layoutOperatingPost.setOnClickListener(this);
        layoutWorkArea.setOnClickListener(this);

    }


    @Override
    public void onError(Exception e) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.layout_OperatingPost:
                //TODO: 点击工作岗位跳转
                Intent intent = new Intent(RecruitScreenActivity.this, TradeSearchActivity.class);
                startActivityForResult(intent, REQUESTCODEFORPOST);
                break;
            case R.id.layout_WorkArea:
                //TODO:点击工作区域的跳转
                Intent intent1 = new Intent(RecruitScreenActivity.this, CitySelectActivity.class);
                startActivityForResult(intent1, REQUESTFORAREA);
                break;

        }

    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        String jobName = "";
        if (requestCode == REQUESTCODEFORPOST) {
            if (resultCode == RESULT_OK) {
                jobName = (String) data.getStringExtra("jobName");
                tvJobPost.setText(jobName);
            } else if (resultCode == 1) {
//                tvJobPost.setText("");
            }

        }
        String areaName = "";
        if (requestCode == REQUESTFORAREA) {
            if (resultCode == RESULT_OK) {
                areaName = (String) data.getStringExtra("areaName");
                tvCityArea.setText(areaName);
            }else if(resultCode==1){
//                tvCityArea.setText("");
            }
        }
    }
}
